`import play.modules.gae.GAE
`import java.text.SimpleDateFormat
`import models.Recipe
`import models.Ingredient.Unit
`args String display, Recipe recipe
`if display.equals("details")
 <article class="details" itemscope itemtype="http://schema.org/Recipe">
 	<div class="`if (recipe.image2 != null){`recipeImgTwo`}else{`recipeImg`}`">
		<a href="@{Application.recipeImage(recipe.code)}"><img itemprop="image"
			src="@{Application.recipeThumb(recipe.code)}" alt="${recipe.name}" title="${recipe.name}"/></a>
		`if (recipe.image2 != null) {
		<a href="@{Application.recipeImage2(recipe.code)}"><img itemprop="image"
			src="@{Application.recipeThumb2(recipe.code)}" alt="${recipe.name}" title="${recipe.name}"/></a>
		`}
 	</div>
 	<h3 itemprop="name">${recipe.name}</h3>
 	Ингредиенты:
 	<table class="ingredients table">
 		`for(Ingredient ingredient: recipe.ingredients.order("unit").fetch()) {
 			`ingredient.product.get();
		<tr>
			<td itemprop="ingredients">${ingredient.product.name}</td>
			`if (ingredient.unit != Unit.NONE){`<td>`t count(ingredient.count, ingredient.unit);`</td>`}`
		</tr>
 		`}
 	</table>
 	<br class="clear"/>
 	<a class="backToRecipesLink" href="@{Application.recipes()}">&larr; Назад к списку</a> 
 	<br class="clear" /> <br class="clear" />
 	<div class="recipeDescription" itemprop="recipeInstructions">${recipe.description}</div>
 	
 	`List<RecipeComment> comments = recipe.comments.fetch();`
 	<h4 id="comments">
 	`if (comments.size() > 0){`Комментарии к рецепту '${recipe.name}': `}else{`Комментариев к рецепту '${recipe.name}' пока нет.`}`
 	</h4>
 	`SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");`
 	`for(RecipeComment comment: comments){
		<div class="comment well">
			<div class="comment-metadata">
				<span class="comment-author">${comment.name},</span> <span
					class="comment-date">${formatter.format(comment.dateCreated)}</span>
			</div>
			<div class="comment-content">${escape(comment.comment)}</div>
		</div>
 	`}
 	
 	`if (GAE.isLoggedIn()) {
	 	<input id="open-comment-form-btn" type="button" class="btn btn-primary" onclick='javascript:$("#comment-form").show();$(this).animate({"opacity":"0"},200, function(){$("#comment-form").animate({"opacity":"1"}, 200)});' value="Оставить комментарий"/>
	 	<form action="@{Application.addRecipeComment()}" method="post" accept-charset="utf-8" enctype="application/x-www-form-urlencoded" class="form-horizontal" id="comment-form">
	 		${authenticityToken()}
	 		<input type="hidden" name="id" value="${recipe.id}"/>
			<fieldset>
				<legend>Комментировать рецепт:</legend>
				<div class="control-group">
					<label class="control-label" for="name">Имя:</label>
					<div class="controls">
						<input type="text" name="name" value="${GAE.getUser()}" class="input-xlarge" disabled="true"/>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="comment">Комментарий:</label>
					<div class="controls">
						<textarea rows="10" cols="20" class="input-xlarge" name="comment">${flash("comment")}</textarea>
						<p class="help-block">Обязательное</p>
						`if (hasError("comment")){`<span class="alert-message error">`error("comment");`</span>`}`
					</div>
				</div>
			</fieldset>
			<div class="form-actions">
				<input type="submit" class="btn btn-primary" value="Комментировать"/>
				<input type="button" class="btn" value="Отменить" onclick="javascript:$('#comment-form').animate({'opacity':'0'}, 400, function(){$('#comment-form').hide();$('#open-comment-form-btn').animate({'opacity':'1'}, 400);});"/>
			</div>
 		</form>
 	`} else {
 		<a href="@{Application.login(request.action, recipe.code)}">Авторизуйтесь</a> чтобы комментировать.
 	`}
 </article>
`else
	<article class="list" itemscope itemtype="http://schema.org/Recipe">
		<div class="recipeImg">
			<a href="@{Application.viewRecipeByCode(recipe.code)}"><img itemprop="image"
				src="@{Application.recipeThumb(recipe.code)}" alt="${recipe.name}" title="${recipe.name}"/></a>
		</div>
		<div class="ingredient-desc">
			<h3 itemprop="name"><a href="@{Application.viewRecipeByCode(recipe.code)}">${recipe.name}</a></h3>
				Ингредиенты:
				<ul class="ingredients-small">
				`final List<Ingredient> ingredients = recipe.ingredients.fetch();`
				`for Ingredient ingredient: ingredients
					`ingredient.product.get();`
					`if (_index < 3 || ingredients.size() == 3) {
						<li itemprop="ingredients">${ingredient.product.name}</li>
					`} else if (_index == 3){
						<li>...</li>
					`}
				`
				</ul>
				`List<RecipeComment> comments = recipe.comments.fetch();`
				<span><a href="@{Application.viewRecipeByCode(recipe.code)}#comments">`if (comments.size() > 0){`Комментариев: ${comments.size()}`}else{`Комментировать рецепт`}`</a></span>
		</div>
	</article>
`